x = input() #one two fivex = x.replace("one", "1") 
x = x.replace("two", "2") 
x = x.replace("three", "3") 
x = x.replace("four", "4") 
x = x.replace("five", "5") 
x = x.replace("six", "6") 
x = x.replace("seven", "7") 
x = x.replace("eight", "8") 
x = x.replace("nine", "9") 
x = x.replace("zero", "0") 
x = x.replace(" ", "") 
x = int(x) 
if x > 999 or x < 100 : 
    print("Wrong input") 
else: 
    count = 0 
    for i in range(1, x + 1):
        if x % i == 0: 
            count += 1 
    if count == 2: 
        print(x) 
    else: 
        for k_right in range(x+1, 10000):
            count = 0 
            for i in range(1, k_right + 1): 
                if k_right % i == 0: 
                    count += 1 
            if count == 2: 
                break 
        for k_left in range(x-1, 0, -1):
            count = 0 
            for i in range(1, k_left + 1): 
                if k_left % i == 0: 
                    count += 1 
            if count == 2: 
                break 
        if k_right - x < x - k_left: 
            print(k_right) 
        else: 
            print(k_left)
